home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
pxewin.zip
/
PXDIS.CPP
< prev
next >
Wrap
Text File
|
1992-02-04
|
6KB
|
241 lines
// PXEWIN - (C) Copyright 1992 by Beam Engineering, INC.
// PXDIS.CPP //
// Contents ----------------------------------------------------------------
//
// This module contains members for interfacing to the PXDIS class.
//
// End ---------------------------------------------------------------------
// External Reference Name for this Header ---------------------------------
#ifndef PXDIS_CPP
#define PXDIS_CPP
// End ---------------------------------------------------------------------
// Interface Dependencies --------------------------------------------------
#ifndef PXDIS_HPP
#include "pxdis.hpp"
#endif // PXDIS_HPP //
// End ---------------------------------------------------------------------
// constructor PXDIS //
inline PXDIS::PXDIS()
{
// NULL out all your field pointer.
my_field = NULL;
// Create some space for a new engine data pointer
EngDataPtr = new EngData;
}
// Summary -----------------------------------------------------------------
//
// Set field pointer to null. Create a Engine Data Pointer as a parent
// PXEngObject.
//
// End ---------------------------------------------------------------------
// member Get of PXDIS //
inline Pchar PXDIS::Get(int i) /* Get the data from the
right field */
{
return my_field[i]->Get();
}
// Summary -----------------------------------------------------------------
//
// Gets the character version of the data in the field.
//
// Return Value
//
// Returns character data.
//
// End ---------------------------------------------------------------------
// member SetUp of PXDIS //
int PXDIS::SetUp(int index,int mode,int op,int display)
{
int i; /* Field index */
FIELDHANDLE fld;
// Null out your pointers in case a delete is called before
// new
my_field = NULL;
my_table = NULL;
my_record = NULL;
// Open the table
my_table = new PXTbl(EngDataPtr->PXEObjPtr);
if(my_table->Open(index,mode,op) != PXSUCCESS)
return EngDataPtr->Errors.pxerr;
// Open record buffer and get the number of records in table
my_record = new PXRec(EngDataPtr->PXEObjPtr);
if(EngDataPtr->Errors.pxerr != PXSUCCESS)
return EngDataPtr->Errors.pxerr;
// Get the number of fields in the table
my_table->NumFlds();
// Make an array of field pointers
my_field = new PPXField [EngDataPtr->num_fields];
// Get the fields initialized
for(i = 0;i < EngDataPtr->num_fields;i++)
{
fld = i + 1;
my_field[i] = new PXField(my_record,fld);
if(EngDataPtr->Errors.pxerr != PXSUCCESS)
return EngDataPtr->Errors.pxerr;
}
return PXSUCCESS;
}
// Summary -----------------------------------------------------------------
//
// This member initializes the table, record and fields of a PDOX
// database.
//
// Parameters --------------------------------------------------------------
//
// name. This is the name of the database.
//
// index. This the index you wish to use.
//
// mode. This is the save mode you wish to open the table with.
//
// op. This is the operation you wish to perform on the table. You
// can also use the create operation.
//
// display. This is the display option you wish to perform. You can
// dislay a single record at a time or a page of records.
//
// Function Description ----------------------------------------------------
//
// 1. Make table object.
//
// 2. Make record object.
//
// 3. Get the number of fields in the table.
//
// 4. Make all your field objects.
//
// End ---------------------------------------------------------------------
// destructor PXDIS //
PXDIS::~PXDIS(void)
{
int i; /* field index */
// if no pointer to my_field then set the number of fields to zero
if(!my_field)
EngDataPtr->num_fields = 0;
for(i = 0;i < EngDataPtr->num_fields;i++)
delete my_field[i];
delete my_field;
delete my_record;
delete my_table;
delete EngDataPtr;
}
// Description -------------------------------------------------------------
//
// 1. Check and see if my_field is NULL. If it is then set num_fields
// to zero so you can pass through the for loop.
//
// 2. Delete the field objects.
//
// 3. Delete the field pointer, record, table and Engine Data Pointers.
//
// End ---------------------------------------------------------------------
// member build of PXDIS //
PTStreamable PXDIS::build()
{
return new PXDIS(streamableInit);
}
TStreamableClass RegPXDIS("PXDIS",PXDIS::build,
__DELTA(PXDIS));
// Description -------------------------------------------------------------
//
// When the streamable constructor is called, TStreamable dispatches
// the build member to construct the object. To do this, it must
// know where to find this member functions for the specific class.
// This is the reason for the stream registration.
//
// End ---------------------------------------------------------------------
// member read of PXDIS //
inline Pvoid PXDIS::read(Ripstream is)
{
PXEngObject::read(is);
// NULL out all your field pointer.
my_field = NULL;
// Create some space for a new engine data pointer
EngDataPtr = new EngData;
return this;
}
// Summary -----------------------------------------------------------------
//
// Read from the stream.
//
// Parameters
//
// is. Is the input stream.
//
// Return Value
//
// Returns a pointer to this object to the TStreamable.
//
// Functional Description
//
// Call the PXEngObject::read member to initialize the error status to
// no errors. Null the field pointer. Create a new Engine Data
// Pointer. Nothing is taken from the stream. This is here because
// the TStreamable constructor calls it.
//
// End ---------------------------------------------------------------------
// member write of PXDIS //
inline void PXDIS::write(Ropstream)
{
}
// Summary -----------------------------------------------------------------
//
// Nothing is put on the stream.
//
// End ---------------------------------------------------------------------
#endif // PXDIS_CPP //